import React, { Component } from 'react'
import Taro from '@tarojs/taro'
import { View, Button, Text } from '@tarojs/components'
import { observer } from 'mobx-react'
import { httpApi } from '../../common/http'
import api from '../../common/API'
import Navbar from '../../components/Navbar'
import CuInput from '../../components/CuInput'

import './index.scss'


@observer
class Index extends Component {
    constructor(props) {
    super(props)
    this.state = {
      value: '222222222222222'
    }
  }
  componentWillMount () {

  }

  componentDidMount () {
      // httpApi(api.login, {
      //     a: 1,
      //     b: 1,
      //     c: 1
      // }, true).then( res => {
      //     console.log(res)
      // })
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  toSubpages = () => {
      Taro.navigateTo({
          url: '../secondPages/test/index'
      })
  }

    getTest = e => {
        e.detail.value = e.detail.value.replace(/\s+/g, '')
        this.setState({
            value: e.detail.value
        })
    }

  render () {
      const sty = {
          width:'90%',
          margin: 'auto'
      }
      let {value} = this.state
    return (
      <View className='index'>
        <Navbar title='首页' />
        <View style={sty}>
            <CuInput value={value} onChange={this.getTest} />
            <CuInput onChange={this.getTest} />
            <CuInput onChange={this.getTest} />
            <CuInput onChange={this.getTest} />
            <CuInput onChange={this.getTest} />
            <CuInput onChange={this.getTest} />
        </View>
      </View>
    )
  }
}

export default Index
